<template>
  <el-row :gutter="20" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
      <div class="card-panel card-panel__lg">
        <DashboardProfile />
      </div>
      
    </el-col>
    <el-col :xs="12" :sm="12" :lg="16" class="card-panel-col">
      <el-row :gutter="20" class="panel-group">
        <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
          <el-row :gutter="20" class="panel-group" style="margin-bottom:20px;">
            <el-col :xs="24" :sm="24" :lg="24" class="card-panel-col">
              <div class="card-panel">
                <div class="card-panel-icon-wrapper">
                  <svg-icon icon-class="liucheng" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    流程定义
                  </div>
                  <count-to :start-val="0" :end-val="24" :duration="2600" class="card-panel-num" @click="handleModels"/><span class="unit">项</span>
                  <div class="card-panel-sub">
                    <p>OA <count-to :start-val="0" :end-val="14" :duration="2600" class="card-panel-num" @click="handleModels('oa')"/></p>
                    <p>工单 <count-to :start-val="0" :end-val="10" :duration="2600" class="card-panel-num" @click="handleModels('workflow')" /></p>
                  </div>
                </div>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="panel-group">
            <el-col :xs="24" :sm="24" :lg="24" class="card-panel-col">
              <div class="card-panel">
                <div class="card-panel-icon-wrapper">
                  <svg-icon icon-class="biaodan" class-name="card-panel-icon" />
                </div>
                <div class="card-panel-description">
                  <div class="card-panel-text">
                    注册表单
                  </div>
                  <count-to :start-val="0" :end-val="31" :duration="2600" class="card-panel-num" @click="handleForms"/><span class="unit">个</span>
                  <div class="card-panel-sub">
                    <p>本地表单 <count-to :start-val="0" :end-val="16" :duration="2600" class="card-panel-num" @click="handleForms('local')"/></p>
                    <p>在线表单 <count-to :start-val="0" :end-val="15" :duration="2600" class="card-panel-num" @click="handleForms('online')" /></p>
                  </div>
                </div>
              </div>
            </el-col>
          </el-row>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="8" :span="24" class="card-panel-col">
          <div class="card-panel card-panel__lg">
            <div class="card-panel-icon-wrapper">
              <svg-icon icon-class="shili" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                流程实例
              </div>
              <count-to :start-val="0" :end-val="132" :duration="2600" class="card-panel-num" @click="handleInstances"/><span class="unit">项</span>
            </div>
            <div class="card-panel-echart">
              <PieChart :options="options1" clickable width="100%" height="150px" @legend-click="handleLegendClick"/>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="8" :span="24" class="card-panel-col">
          <div class="card-panel card-panel__lg">
            <div class="card-panel-icon-wrapper">
              <svg-icon icon-class="renwu" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                任务
              </div>
              <count-to :start-val="0" :end-val="205" :duration="2600" class="card-panel-num" @click="handleTasks"/><span class="unit">项</span>
            </div>
            <div class="card-panel-echart">
              <PieChart :options="options2" width="100%" height="150px" clickable  @legend-click="handleLegendClick" />
            </div>
          </div>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import DashboardProfile from './Profile.vue'
import PieChart from './PieChart.vue'

export default {
  components: {
    CountTo,
    DashboardProfile,
    PieChart
  },
  data() {
    return {
      options1: {
        color: ['#FF7F50','#dd6236','#8f1e00'],
        legend: {
          orient: 'vertical',
          left: 15,
          bottom: 30,
          itemWidth: 14,
          itemHeight: 14,
          icon: "circle",
          itemStyle: {
            fontSize: 12
          },
          textStyle:{
            lineHeight: 14
          },
        },
        series: [
          {
            name: '流程实例',
            type: 'pie',
            radius: ['40%', '75%'],
            avoidLabelOverlap: false,
            left: '45%',
            itemStyle: {
              borderRadius: 10,
              borderColor: '#fff',
              borderWidth: 2
            },
            label: {
              show: false,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 48, name: '激活中' },
              { value: 12, name: '已挂起' },
              { value: 78, name: '已完结' }
            ]
          }
        ]
      },
      options2: {
        color: ['#b6ccd8','#71c4ef','#00668c'],
        legend: {
          orient: 'vertical',
          left: 15,
          bottom: 30,
          itemWidth: 14,
          itemHeight: 14,
          icon: "circle",
          itemStyle: {
            fontSize: 12
          },
          textStyle:{
            lineHeight: 14
          }
        },
        series: [
          {
            name: '流程实例',
            type: 'pie',
            radius: ['40%', '75%'],
            avoidLabelOverlap: false,
            left: '45%',
            itemStyle: {
              borderRadius: 10,
              borderColor: '#fff',
              borderWidth: 2
            },
            label: {
              show: false,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 97, name: '进行中' },
              { value: 23, name: '已完成' },
              { value: 20, name: '已驳回' }
            ]
          }
        ]
      },
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.$emit('handleSetLineChartData', type)
    },
    handleModels(type){

    },
    handleForms(type){

    },
    handleInstances(){

    },
    handleTasks(){

    },
    handleLegendClick(val){
      console.log("handleLegendClick===>",val)
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {

  .card-panel-echart{
    padding:20px;
  }
  .card-panel-col {
    
  }

  .card-panel {
    height: 140px;
    // cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);
    border-radius: 10px;

    &:hover {
      box-shadow: 5px 5px 10px rgba(0, 0, 0, .1);
    }

    // &:hover {
    //   .card-panel-icon-wrapper {
    //     color: #fff;
    //   }

    //   .icon-people {
    //     background: #40c9c6;
    //   }

    //   .icon-message {
    //     background: #36a3f7;
    //   }

    //   .icon-money {
    //     background: #f4516c;
    //   }

    //   .icon-shopping {
    //     background: #34bfa3
    //   }
    // }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      position: absolute;
      right:10px;
      top:10px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      font-size: 32px;
    }

    .card-panel-description {
      font-weight: bold;
      margin: 26px 26px 16px 26px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 14px;
        margin-bottom: 2px;
      }

      .card-panel-num {
        font-size: 42px;
        color:#000;
      }
      .unit{
        color:#222;
        font-size:12px;
      }

      .card-panel-sub{
        margin-top:10px;
        display: flex;
        p{
          margin:0 10px 0 0;
          padding-right:10px;
          color:#767676;
          line-height: 0.8;
          border-right: 1px solid #aaa;

          &:last-child{
            border-right: none;
          }
        }
        .card-panel-num{
          font-size:12px;
          font-weight: bold;
          // color:#36a3f7;
        }
      }
    }
  }
  .card-panel__lg{
    height: 300px;
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
